<template>
	<view class="content">
		<view class="component-list" v-for="(item,index) in componentList" :key="index">
			<view class="items-center" @click="goComponent(item)">
				<view class="logo">
					<image class="icon" :src="item.imgUrl" mode=""></image>
				</view>
				<view class="text-area">
					<text class="title">{{item.componentName}}</text>
				</view>
			</view>
		</view>

	</view>
</template>

<script setup lang="ts">
	import { ref, reactive } from 'vue'
	const componentList = reactive([
		{
			id: 1,
			componentName: '按钮组件',
			imgUrl: '../../static/logo.png',
			url: '/pages/Button/Button'
		},
		{
			id: 1,
			componentName: '相机组件',
			imgUrl: '../../static/logo.png',
			url: '/pages/CameraCapture/CameraCapture'
		},
		{
			id: 1,
			componentName: '倒计时组件',
			imgUrl: '../../static/logo.png',
			url: '/pages/CountDown/CountDown'
		},
		{
			id: 1,
			componentName: '滑动日期选择器组件',
			imgUrl: '../../static/logo.png',
			url: '/pages/DatePicker/DatePicker'
		},
		{
			id: 1,
			componentName: '身高体重滑动选择器组件',
			imgUrl: '../../static/logo.png',
			url: '/pages/HeightWeightPicker/HeightWeightPicker'
		},
		{
			id: 1,
			componentName: '语音转文字组件',
			imgUrl: '../../static/logo.png',
			url: '/pages/Voice/Voice'
		}
	])

	const goComponent = (item : any) => {
		console.log('跳转', item.componentName)
		uni.navigateTo({
			url: item.url,
			success: () => console.log('跳转成功'),
			fail: (err) => {
				console.error('跳转失败：', err);
			}
		})
	}
</script>

<style lang="scss" scoped>
	.content {
		width: 100vw;
		height: 100vh;
		display: flex;
		flex-direction: column;

		.component-list {
			margin-top: 20rpx;
			width: auto;
			height: 150rpx;
			gap: 20rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			background-color: beige;

			.logo {
				display: flex;
				align-items: center;
				justify-content: center;
				width: auto;

				.icon {
					height: 100rpx;
					width: 100rpx;
				}
			}

			.text-area {
				width: auto;
				height: auto;
				display: flex;
				justify-content: center;
				align-items: center;

				.title {
					font-size: 40rpx;
					color: #333333;
				}
			}
		}
	}
</style>